package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.product.RCAnonymouseProductEntryRoot;
import com.shrct.businessprocess.product.impl.RCAnonymouseProductEntryRootImpl;
import com.shrct.businessprocess.purchase.RCAnonymousProductInStockEvent;
import com.shrct.businessprocess.purchase.impl.RCProductInStockEventImpl;
import com.shrct.businessprocess.purchase.proxy.RCAnonymousProductInStockEventProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCANONYMOUSPRODUCTINSTOCKEVENT_TYPE")
public class RCAnonymousProductInStockEventImpl extends RCProductInStockEventImpl implements RCAnonymousProductInStockEvent {
  public RCAnonymousProductInStockEventImpl() {
    super();
  }
  
  public RCAnonymousProductInStockEventImpl(final RCAnonymouseProductEntryRoot entityRoot) {
    super();
    this.entityRoot = entityRoot;
  }
  
  @JoinColumn(name = "entityRoot_id")
  @ManyToOne(targetEntity = RCAnonymouseProductEntryRootImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCAnonymouseProductEntryRoot entityRoot;
  
  public RCAnonymouseProductEntryRoot getEntityRoot() {
    return this.entityRoot;
  }
  
  public RCAnonymousProductInStockEvent setEntityRoot(final RCAnonymouseProductEntryRoot entityRoot) {
    this.entityRoot = entityRoot;
    return this;			
    
  }
  
  public static RCAnonymousProductInStockEvent create(final RCAnonymouseProductEntryRoot entityRoot, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCAnonymousProductInStockEvent rCAnonymousProductInStockEvent = new com.shrct.businessprocess.purchase.impl.RCAnonymousProductInStockEventImpl(
    	entityRoot
    );
    objectFactory.create(rCAnonymousProductInStockEvent);
    return rCAnonymousProductInStockEvent;			
    
  }
  
  public static RCAnonymousProductInStockEvent createRCAnonymousProductInStockEventImpl(final RCAnonymouseProductEntryRoot entityRoot, final IObjectFactory objectFactory, final Procedure1<RCAnonymousProductInStockEvent> init) {
    com.shrct.businessprocess.purchase.RCAnonymousProductInStockEvent rCAnonymousProductInStockEvent = new com.shrct.businessprocess.purchase.impl.RCAnonymousProductInStockEventImpl(
    	entityRoot
    );
    objectFactory.create(rCAnonymousProductInStockEvent);
    init.apply(rCAnonymousProductInStockEvent);
    
    return rCAnonymousProductInStockEvent;			
    
  }
  
  public RCAnonymousProductInStockEventProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCAnonymousProductInStockEventProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCAnonymousProductInStockEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
